"""
序列化器
"""

from rest_framework import serializers
from goods.models import GoodsVisitCount

# 真丢GoodsVisitCount定义序列化器
class GoodsVisitCountModelSerializer(serializers.ModelSerializer):
    # 由于关联字段category默认映射的类型为PrimaryKeyRelatedField,序列化结果为主键值
    # 所以此处重写定义类型为StringRelatedField
    category = serializers.StringRelatedField()

    class Meta:
        model = GoodsVisitCount
        fields = ['category', 'count']